package com.bleeth.fx.component;

import javafx.beans.property.SimpleStringProperty;
import javafx.scene.control.RadioButton;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.HBox;
import lombok.Builder;

import java.util.ArrayList;
import java.util.List;


/**
 * @author Sakura
 * @version 1.0
 * @date 2021-11-13 22:17
 **/
@Builder
public class MRadio {


    @Builder.Default
    private boolean disabled = false;

    @Builder.Default
    private boolean border = false;

    @Builder.Default
    private boolean loading = false;

    @Builder.Default
    private double width = DEFAULT_WIDTH;

    @Builder.Default
    private double height = DEFAULT_HEIGHT;

    private List<RadioButton> rbList = new ArrayList<>();


    private static final double DEFAULT_WIDTH = 95;
    private static final double DEFAULT_HEIGHT = 40;
    private static final double DEFAULT_RADIUS = 5;

    public MRadio addItem(String value) {
        RadioButton rb = new RadioButton(value);
        rbList.add(rb);
        return this;
    }

    
    public MRadio addItem(SimpleStringProperty _value) {
        RadioButton rb = new RadioButton();
        rb.textProperty().bind(_value);
        rbList.add(rb);
        return this;
    }

    public HBox make() {
        HBox hbox = new HBox();
        ToggleGroup group = new ToggleGroup();
        for (RadioButton radioButton : rbList) {
            radioButton.setToggleGroup(group);
        }

        //设置样式


        return hbox;
    }


}
